package com.example.chengzhong.controller;

import com.example.chengzhong.service.SerialPortService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class SerialPortInitializer implements ApplicationRunner {
    private final SerialPortService serialPortService;

    // 依赖注入
    public SerialPortInitializer(SerialPortService serialPortService) {
        this.serialPortService = serialPortService;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 从配置读取参数（如application.yml）
        serialPortService.initPort("COM1", 1200,"1925755778764468225"); // 磅秤1
//        serialPortService.initPort("COM3", 1200,"1925755778764468226"); // 磅秤2
    }
}
